7 class WikiMapTest
extends MediaWikiLangTestCase
{
9 public function setUp() {
12 $conf = new SiteConfiguration();
13 $conf->settings
= array(
15 'enwiki' => 'http://en.example.org',
16 'ruwiki' => '//ru.example.org',
18 'wgArticlePath' => array(
20 'ruwiki' => '/wiki/$1',
23 $conf->suffixes
= array( 'wiki' );
24 $this->setMwGlobals( array(
29 public function provideGetWiki() {
30 $enwiki = new WikiReference( 'http://en.example.org', '/w/$1' );
31 $ruwiki = new WikiReference( '//ru.example.org', '/wiki/$1' );
34 'unknown' => array( false, 'xyzzy' ),
35 'enwiki' => array( $enwiki, 'enwiki' ),
36 'ruwiki' => array( $ruwiki, 'ruwiki' ),
41 * @dataProvider provideGetWiki
43 public function testGetWiki( $expected, $wikiId ) {
44 $this->assertEquals( $expected, WikiMap
::getWiki( $wikiId ) );
47 public function provideGetWikiName() {
49 'unknown' => array( 'xyzzy', 'xyzzy' ),
50 'enwiki' => array( 'en.example.org', 'enwiki' ),
51 'ruwiki' => array( 'ru.example.org', 'ruwiki' ),
56 * @dataProvider provideGetWikiName
58 public function testGetWikiName( $expected, $wikiId ) {
59 $this->assertEquals( $expected, WikiMap
::getWikiName( $wikiId ) );
62 public function provideMakeForeignLink() {
64 'unknown' => array( false, 'xyzzy', 'Foo' ),
66 '<a class="external" rel="nofollow" ' .
67 'href="http://en.example.org/w/Foo">Foo</a>',
72 '<a class="external" rel="nofollow" ' .
73 'href="//ru.example.org/wiki/%D0%A4%D1%83">вар</a>',
82 * @dataProvider provideMakeForeignLink
84 public function testMakeForeignLink( $expected, $wikiId, $page, $text = null ) {
87 WikiMap
::makeForeignLink( $wikiId, $page, $text )
91 public function provideForeignUserLink() {
93 'unknown' => array( false, 'xyzzy', 'Foo' ),
95 '<a class="external" rel="nofollow" ' .
96 'href="http://en.example.org/w/User:Foo">User:Foo</a>',
101 '<a class="external" rel="nofollow" ' .
102 'href="//ru.example.org/wiki/User:%D0%A4%D1%83">вар</a>',
111 * @dataProvider provideForeignUserLink
113 public function testForeignUserLink( $expected, $wikiId, $user, $text = null ) {
114 $this->assertEquals( $expected, WikiMap
::foreignUserLink( $wikiId, $user, $text ) );
117 public function provideGetForeignURL() {
119 'unknown' => array( false, 'xyzzy', 'Foo' ),
120 'enwiki' => array( 'http://en.example.org/w/Foo', 'enwiki', 'Foo' ),
121 'ruwiki with fragment' => array(
122 '//ru.example.org/wiki/%D0%A4%D1%83#%D0%B2%D0%B0%D1%80',
131 * @dataProvider provideGetForeignURL
133 public function testGetForeignURL( $expected, $wikiId, $page, $fragment = null ) {
134 $this->assertEquals( $expected, WikiMap
::getForeignURL( $wikiId, $page, $fragment ) );